package vn.gq.tym.utils;

import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.widget.Toast;

public class GooglePlay {
	
	public static void startAcitivityForDetail(Context context) {
		try {
			Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(String.format("market://details?id=%s", context.getPackageName())));
			context.startActivity(intent);
		} catch(ActivityNotFoundException e) {
			Toast.makeText(context, "Máy bạn chưa cài đặt ứng dụng Google Play !", Toast.LENGTH_SHORT).show();
		}
	}
	
	public static void startActivityForPub(Context context, String strUri) {
		try {
			Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(String.format("market://search?q=%s", strUri)));
			context.startActivity(intent);
		} catch(ActivityNotFoundException e) {
			Toast.makeText(context, "Máy bạn chưa cài đặt ứng dụng Google Play !", Toast.LENGTH_SHORT).show();
		}
	}
	
	public static void choosePublisherPlay(final Context context) {
		DialogHelper.showConfirm(context, "CHỌN KHO ỨNG DỤNG", "UNGDUNGVIET", "VEGASOFT", new IDialogHelper() {
			
			@Override
			public void onOk() {
				startActivityForPub(context, "pub:\"UNG DUNG VIET\"");
			}
			
			@Override
			public void onCancel() {
				startActivityForPub(context, "pub:VEGASOFT");
			}
		}, true);
	}
	
}
